#ifndef _EXAMPLE_H_
#define _EXAMPLE_H_

#include <stdbool.h>
#include <stddef.h>
#include "cJSON.h"

typedef struct {
	char *NestedObject;
} ArrayObject;

typedef struct {
	int   *Elements;
	size_t Count;
} IntArray;

typedef enum { AR_ELEMENT_STRING, AR_ELEMENT_INT, AR_ELEMENT_BOOL, AR_ELEMENT_OBJECT, AR_ELEMENT_ARRAY } ArrayElementType;

typedef struct ArrayElement {
	ArrayElementType Type;
	union {
		char        *StringValue;
		int          IntValue;
		bool         BoolValue;
		ArrayObject *ObjectValue;
		IntArray    *ArrayValue;
	};
} ArrayElement;

typedef struct {
	ArrayElement *Elements;
	size_t        Count;
} JsonArray;

typedef struct {
	int  Id;
	bool Active;
} NestedArrayElement;

typedef struct {
	NestedArrayElement *Elements;
	size_t              Count;
} NestedArray;

typedef struct {
	char       *Key;
	NestedArray NestedArray;
} JsonObject;

typedef struct {
	int dummy; // Placeholder for empty object
} EmptyObject;

typedef enum { MIXED_NULL, MIXED_STRING, MIXED_INT, MIXED_BOOL, MIXED_OBJECT } MixedType;

typedef struct MixedObject MixedObject;

typedef struct {
	MixedType Type;
	union {
		char        *StringValue;
		int          IntValue;
		bool         BoolValue;
		MixedObject *ObjectValue;
	};
} MixedElement;

struct MixedObject {
	MixedElement *Complex;
	size_t        Count;
};

typedef struct {
	MixedElement *Elements;
	size_t        Count;
} MixedTypesArray;

typedef struct {
	char           *String;
	int             Number;
	double          Float;
	bool            Boolean;
	void           *NullValue;
	JsonArray       Array;
	JsonObject      Object;
	JsonArray       EmptyArray;
	EmptyObject     EmptyObject;
	MixedTypesArray MixedTypes;
} JsonData;

// 辅助函数声明
JsonArray       ParseArray(cJSON *array);
JsonObject      ParseObject(cJSON *obj);
MixedTypesArray ParseMixedArray(cJSON *array);

void PrintArray(const JsonArray *array);
void PrintObject(const JsonObject *obj);
void PrintMixedTypes(const MixedTypesArray *mixed);

JsonData *ParseJsonData(const char *filename);
void      PrintJsonData(const JsonData *data);

#endif // _EXAMPLE_H_